package com.sbs.gaoxinqutoilet.fragment;

import android.Manifest;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewStub;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.appcompat.widget.ListPopupWindow;
import androidx.appcompat.widget.Toolbar;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;

import com.bumptech.glide.Glide;
import com.google.gson.reflect.TypeToken;
import com.lvfq.pickerview.TimePickerView;
import com.sbs.gaoxinqutoilet.R;
import com.sbs.gaoxinqutoilet.base.BaseBackFragment;
import com.sbs.gaoxinqutoilet.entity.AcceptImageEntity;
import com.sbs.gaoxinqutoilet.entity.AddNewBuildTypeEntity;
import com.sbs.gaoxinqutoilet.entity.AddNewShiGongTeamEntity;
import com.sbs.gaoxinqutoilet.entity.FIleEditSaveUpEntity;
import com.sbs.gaoxinqutoilet.entity.MessageEvent;
import com.sbs.gaoxinqutoilet.entity.ReBuildItemEntity;
import com.sbs.gaoxinqutoilet.entity.RebuildDetialEntity;
import com.sbs.gaoxinqutoilet.entity.RebuildInfoEntity;
import com.sbs.gaoxinqutoilet.entity.UploadFileCustomEntity;
import com.sbs.gaoxinqutoilet.entity.UploadImageEntity;
import com.sbs.gaoxinqutoilet.eventbus.EventCenter;
import com.sbs.gaoxinqutoilet.eventbus.StartNewFragmentEvent;
import com.sbs.gaoxinqutoilet.http.HttpApis;
import com.sbs.gaoxinqutoilet.http.Request;
import com.sbs.gaoxinqutoilet.interfaces.AddNewBuildTypePopuListener;
import com.sbs.gaoxinqutoilet.interfaces.AddNewShigTeamPopuListener;
import com.sbs.gaoxinqutoilet.interfaces.DialogClick;
import com.sbs.gaoxinqutoilet.interfaces.EventConstant;
import com.sbs.gaoxinqutoilet.utils.GsonTools;
import com.sbs.gaoxinqutoilet.utils.HttpUtils;
import com.sbs.gaoxinqutoilet.utils.ImageLoaderUtils;
import com.sbs.gaoxinqutoilet.utils.JsonUtil;
import com.sbs.gaoxinqutoilet.utils.LogUtils;
import com.sbs.gaoxinqutoilet.utils.TimeUtils;
import com.sbs.gaoxinqutoilet.utils.Util;
import com.sbs.gaoxinqutoilet.utils.UtilPop;
import com.sbs.gaoxinqutoilet.utils.appinstallerutils.ConstUtils;
import com.zhy.autolayout.AutoLinearLayout;
import com.zhy.autolayout.AutoRelativeLayout;
import com.zhy.http.okhttp.OkHttpUtils;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;

import java.io.File;
import java.lang.reflect.Type;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

import io.reactivex.Flowable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull;
import io.reactivex.functions.Consumer;
import io.reactivex.functions.Function;
import io.reactivex.schedulers.Schedulers;
import me.codeboy.android.aligntextview.CBAlignTextView;
import me.iwf.photopicker.PhotoPicker;
import top.zibin.luban.Luban;

import static com.sbs.gaoxinqutoilet.utils.JsonUtil.json2Collection;

/**
 * Created by 聪明一只哈 on 2018/6/4.
 * Time: 2018/6/4  10:00
 */

public class ToiletRebuildDetialFragment extends BaseBackFragment implements View.OnClickListener {

    //假数据,传过来的值  存储在Bundle中
    private static final String REBUILDDATA = "rebuilddatabean";

    private static final int LAYOUT_ONE = 0;
    private static final int LAYOUT_TWO = 1;
    private static final int LAYOUT_THREE = 2;


    private View view;
    private RelativeLayout a_rl_title;
    private ImageView a_image_arrow;
    private LinearLayout rebuild_reform_state_show_body;
    private CBAlignTextView a_tv_locate;
    private CBAlignTextView a_tv_add;
    private CBAlignTextView a_tv_doorname;
    private CBAlignTextView a_tv_househole_name;
    private CBAlignTextView a_tv_id_num;
    private TextView a_tv_isidle;
    private TextView a_tv_build_state;
    private TextView a_tv_build_type;
    private TextView a_tv_team_name;
    private TextView a_tv_material;
    private ImageView idcard_image;
    private ImageView frontdoor_image;
    private ImageView befor_image;
    private ImageView ing_image;
    private ImageView after_image;
    private TextView b_ques_one;
    private TextView b_ques_two;
    private TextView b_ques_three;
    private TextView b_ques_four;
    private TextView b_ques_five;
    private TextView b_ques_six;
    private TextView b_ques_seven;
    private TextView b_ques_eight;
    private TextView b_ques_nine;
    private RelativeLayout c_rl_title;
    private ImageView c_image_arrow;
    private LinearLayout rebuild_check_state_show_body;

    private RelativeLayout d_rl_title;
    private ImageView d_image_arrow;
    private LinearLayout rebuild_info_state_show_body;
    private CBAlignTextView d_state_name;
    private CBAlignTextView d_state_address;
    private CBAlignTextView d_state_trascode;
    private CBAlignTextView d_state_tel;
    private TextView e_date_picker;
    private TextView e_type_selected;
    private TextView e_type_teamname;
    private TextView rebuild_rest_huafeichi;
    private Button e_bt_save;

    private ScrollView applyBuySv;
    private ImageView toolbarBack;
    private TextView toolbarTitle;
    private Toolbar toolbar;


    private RelativeLayout b_rl_title;
    private ImageView b_image_arrow;
    private LinearLayout check_accept_show_body;


    //请求码与结果码
    public static final int IMAGE_ITEM_ADD = -1;
    public static final int REQUEST_CODE_SELECT = 100;
    public static final int REQUEST_CODE_PREVIEW = 101;
    //设置最大的图片数量
    private int maxImgCount = 8;
    private ViewStub rebuild_infalte_five;
    private TimePickerView pvTime;
    private ListPopupWindow buildtype_popupWindow;


    //改造类型
    List<AddNewBuildTypeEntity> buildtype_resaultlist = new ArrayList<>();
    //施工队名称
    List<AddNewShiGongTeamEntity> buildteam_resaultlist = new ArrayList<>();

    private ListPopupWindow buildteam_popupWindow;
    private AutoLinearLayout detialLl;
    private TextView cheigher_one_ch;
    private TextView cheigher_two_ch;
    private TextView cheigher_three_ch;
    private TextView cheigher_four_ch;
    private TextView cheigher_five_ch;
    private TextView cheigher_six_ch;
    private TextView cheigher_seven_ch;
    private TextView cheigher_eight_ch;
    private TextView cheigher_nine_ch;
    private AutoRelativeLayout e_rebuild_up_one;
    private AutoRelativeLayout e_rebuild_up_two;
    private ImageView e_rebuild_image_a;
    private ImageView e_rebuild_image_b;
    private ReBuildItemEntity.DataBean rebuildData;
    private RebuildDetileRequest request;
    private RebuildDetialEntity ewbuildDetialentity;


    //拼接参数
    private Map<String, String> saveparams = new TreeMap<>();
    //临时状态
    private boolean isUploadSuccess;
    private int mLayoutType = -1;
    private UploadFileCustomEntity uploadFileCustomEntity;
    private AutoLinearLayout all_show_a;
    private AutoLinearLayout all_show_b;
    private ArrayList<AcceptImageEntity> acceptImageEntities;

    private RebuildInfoEntity rebuildInfoEntity = new RebuildInfoEntity();


    private String[] before_ima = new String[]{null, null, null, null, null, null, null};
    private String[] ing_ima = new String[]{null, null, null, null, null, null, null};
    private String[] after_ima = new String[]{null, null, null, null, null, null, null};
    private String[] idcard_ima = new String[]{null, null, null, null, null, null, null};
    private String[] fodoor_ima = new String[]{null, null, null, null, null, null, null};


    private String[] one_ima = new String[]{null, null, null, null, null, null, null};
    private String[] two_ima = new String[]{null, null, null, null, null, null, null};
    private AutoLinearLayout allcceptanceuafeichi;
    private TextView tvIdcardIma;
    private TextView tvFrontdoorIma;
    private TextView tvIngIma;
    private TextView tvBeforIma;
    private TextView tvAfterIma;
    private AutoRelativeLayout five_rl_title;
    private ImageView five_rl_image_arrow;
    private AutoLinearLayout five_rl_body;
    private TextView b_ques_five_six;
    private TextView b_ques_five_seven;
    private TextView b_ques_five_eight;
    private TextView b_ques_five_nine;
    private TextView b_ques_five_ten;
    private TextView b_ques_five_eleven;
    private TextView b_ques_five_twelve;
    private TextView cheigher_five_six_ch;
    private TextView cheigher_five_seven_ch;
    private TextView cheigher_five_eight_ch;
    private TextView cheigher_five_nine_ch;
    private TextView cheigher_five_ten_ch;
    private TextView cheigher_five_eleven_ch;
    private TextView cheigher_five_twelve_ch;
    private CBAlignTextView a_tv_humans;
    private CBAlignTextView a_tv_phone;
    private TextView a_tv_bianchi;
    private TextView a_tv_chongshui;
    private TextView a_tv_cefang;
    private TextView b_ques_half;
    private TextView cheigher_half_ch;


    public static ToiletRebuildDetialFragment newInstance(ReBuildItemEntity.DataBean Rewbuilddata) {

        Bundle args = new Bundle();
        args.putSerializable(REBUILDDATA, Rewbuilddata);
        ToiletRebuildDetialFragment fragment = new ToiletRebuildDetialFragment();
        fragment.setArguments(args);
        return fragment;
    }

    private Handler handler = new Handler() {

        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            switch (msg.what) {
                case LAYOUT_ONE:
                    loadLayoutOne();
                    break;
                case LAYOUT_TWO:
                    loadLayoutTwo();
                    break;
                case LAYOUT_THREE:
                    initView(view);
                    initListener();
                    loadMoreData();
                    break;
                default:

            }
        }
    };

    /**
     * 加载前两个ViewStub
     * 先加载前3个
     */
    private void loadLayoutOne() {
        ViewStub rebuild_infalte_one = (ViewStub) view.findViewById(R.id.rebuild_detial_state);
        ViewStub rebuild_infalte_two = (ViewStub) view.findViewById(R.id.rebuild_detial_acceptance);
        ViewStub rebuild_infalte_three = (ViewStub) view.findViewById(R.id.rebuild_detial_check);

        //第一个ViewStub初始化  户厕改造情况
        View inflate_a = rebuild_infalte_one.inflate();
        //a的顶部条目
        a_rl_title = (RelativeLayout) inflate_a.findViewById(R.id.rebuild_reform_state_title);
        a_image_arrow = (ImageView) inflate_a.findViewById(R.id.rebuild_reform_state_iv_arrow);
        rebuild_reform_state_show_body = (LinearLayout) inflate_a.findViewById(R.id.rebuild_reform_state_show_body);
        a_tv_locate = (CBAlignTextView) inflate_a.findViewById(R.id.rebuild_reform_state_located_address);
        a_tv_add = (CBAlignTextView) inflate_a.findViewById(R.id.rebuild_reform_state_door_num);
        a_tv_doorname = (CBAlignTextView) inflate_a.findViewById(R.id.rebuild_reform_state_door_name);
        a_tv_househole_name = (CBAlignTextView) inflate_a.findViewById(R.id.rebuild_reform_state_househole_num);
        a_tv_id_num = (CBAlignTextView) inflate_a.findViewById(R.id.rebuild_reform_state_id_num);

        a_tv_humans = (CBAlignTextView) inflate_a.findViewById(R.id.rebuild_reform_state_humans);
        a_tv_phone = (CBAlignTextView) inflate_a.findViewById(R.id.rebuild_reform_state_phone);

        a_tv_isidle = (TextView) inflate_a.findViewById(R.id.rebuild_reform_state_idle);
        a_tv_build_state = (TextView) inflate_a.findViewById(R.id.rebuild_reform_state_build_state);
        a_tv_build_type = (TextView) inflate_a.findViewById(R.id.rebuild_reform_state_build_type);
        a_tv_team_name = (TextView) inflate_a.findViewById(R.id.rebuild_reform_state_team_name);
        a_tv_material = (TextView) inflate_a.findViewById(R.id.rebuild_reform_state_material);

        idcard_image = (ImageView) inflate_a.findViewById(R.id.rebuild_reform_state_idcard_image);
        frontdoor_image = (ImageView) inflate_a.findViewById(R.id.rebuild_reform_state_frontdoor_image);
        befor_image = (ImageView) inflate_a.findViewById(R.id.rebuild_reform_state_befor_image);
        ing_image = (ImageView) inflate_a.findViewById(R.id.rebuild_reform_state_ing_image);
        after_image = (ImageView) inflate_a.findViewById(R.id.rebuild_reform_state_after_image);

        tvIdcardIma = (TextView) inflate_a.findViewById(R.id.tv_idcard_ima);
        tvFrontdoorIma = (TextView) inflate_a.findViewById(R.id.tv_frontdoor_ima);
        tvIngIma = (TextView) inflate_a.findViewById(R.id.tv_ing_ima);
        tvBeforIma = (TextView) inflate_a.findViewById(R.id.tv_befor_ima);
        tvAfterIma = (TextView) inflate_a.findViewById(R.id.tv_after_ima);


        a_tv_bianchi = (TextView) inflate_a.findViewById(R.id.rebuild_reform_state_bianchi);
        a_tv_chongshui = (TextView) inflate_a.findViewById(R.id.rebuild_reform_state_chongshui);
        a_tv_cefang = (TextView) inflate_a.findViewById(R.id.rebuild_reform_state_cefang);

        //第二个ViewStub初始化  户厕验收情况
        View inflate_b = rebuild_infalte_two.inflate();
        b_rl_title = (RelativeLayout) inflate_b.findViewById(R.id.rebuild_detial_accept_title);
        b_image_arrow = (ImageView) inflate_b.findViewById(R.id.rebuild_detial_accept_iv_arrow);
        check_accept_show_body = (LinearLayout) inflate_b.findViewById(R.id.check_accept_show_body);

        b_ques_half = (TextView) inflate_b.findViewById(R.id.rdcs_tv_resault_half);
        b_ques_one = (TextView) inflate_b.findViewById(R.id.rdcs_tv_resault_one);
        b_ques_two = (TextView) inflate_b.findViewById(R.id.rdcs_tv_resault_two);
        b_ques_three = (TextView) inflate_b.findViewById(R.id.rdcs_tv_resault_three);
        b_ques_four = (TextView) inflate_b.findViewById(R.id.rdcs_tv_resault_four);
        b_ques_five = (TextView) inflate_b.findViewById(R.id.rdcs_tv_resault_five);

        b_ques_five_six = (TextView) inflate_b.findViewById(R.id.rdcs_tv_resault_five_six);
        b_ques_five_seven = (TextView) inflate_b.findViewById(R.id.rdcs_tv_resault_five_seven);
        b_ques_five_eight = (TextView) inflate_b.findViewById(R.id.rdcs_tv_resault_five_eight);
        b_ques_five_nine = (TextView) inflate_b.findViewById(R.id.rdcs_tv_resault_five_nine);
        b_ques_five_ten = (TextView) inflate_b.findViewById(R.id.rdcs_tv_resault_five_ten);
        b_ques_five_eleven = (TextView) inflate_b.findViewById(R.id.rdcs_tv_resault_five_eleven);
        b_ques_five_twelve = (TextView) inflate_b.findViewById(R.id.rdcs_tv_resault_five_twelve);

        b_ques_six = (TextView) inflate_b.findViewById(R.id.rdcs_tv_resault_six);
        b_ques_seven = (TextView) inflate_b.findViewById(R.id.rdcs_tv_resault_seven);
        b_ques_eight = (TextView) inflate_b.findViewById(R.id.rdcs_tv_resault_eight);
        b_ques_nine = (TextView) inflate_b.findViewById(R.id.rdcs_tv_resault_nine);


        //第三个ViewStub初始化  户厕检查情况  与第二个相同只不过是级别更高
        View inflate_c = rebuild_infalte_three.inflate();
        c_rl_title = (RelativeLayout) inflate_c.findViewById(R.id.rebuild_check_state_title);
        c_image_arrow = (ImageView) inflate_c.findViewById(R.id.rebuild_check_state_iv_arrow);
        rebuild_check_state_show_body = (LinearLayout) inflate_c.findViewById(R.id.check_accept_show_body_ch);


        cheigher_half_ch = (TextView) inflate_c.findViewById(R.id.rdcs_tv_resault_half_ch);
        cheigher_one_ch = (TextView) inflate_c.findViewById(R.id.rdcs_tv_resault_one_ch);
        cheigher_two_ch = (TextView) inflate_c.findViewById(R.id.rdcs_tv_resault_two_ch);
        cheigher_three_ch = (TextView) inflate_c.findViewById(R.id.rdcs_tv_resault_three_ch);
        cheigher_four_ch = (TextView) inflate_c.findViewById(R.id.rdcs_tv_resault_four_ch);
        cheigher_five_ch = (TextView) inflate_c.findViewById(R.id.rdcs_tv_resault_five_ch);

        cheigher_five_six_ch = (TextView) inflate_c.findViewById(R.id.rdcs_tv_resault_five_six_ch);
        cheigher_five_seven_ch = (TextView) inflate_c.findViewById(R.id.rdcs_tv_resault_five_seven_ch);
        cheigher_five_eight_ch = (TextView) inflate_c.findViewById(R.id.rdcs_tv_resault_five_eight_ch);
        cheigher_five_nine_ch = (TextView) inflate_c.findViewById(R.id.rdcs_tv_resault_five_nine_ch);
        cheigher_five_ten_ch = (TextView) inflate_c.findViewById(R.id.rdcs_tv_resault_five_ten_ch);
        cheigher_five_eleven_ch = (TextView) inflate_c.findViewById(R.id.rdcs_tv_resault_five_eleven_ch);
        cheigher_five_twelve_ch = (TextView) inflate_c.findViewById(R.id.rdcs_tv_resault_five_twelve_ch);

        cheigher_six_ch = (TextView) inflate_c.findViewById(R.id.rdcs_tv_resault_six_ch);
        cheigher_seven_ch = (TextView) inflate_c.findViewById(R.id.rdcs_tv_resault_seven_ch);
        cheigher_eight_ch = (TextView) inflate_c.findViewById(R.id.rdcs_tv_resault_eight_ch);
        cheigher_nine_ch = (TextView) inflate_c.findViewById(R.id.rdcs_tv_resault_nine_ch);


    }


    /**
     * 加载前两个ViewStub
     * 再加载后2个
     */
    private void loadLayoutTwo() {
        ViewStub rebuild_infalte_four = (ViewStub) view.findViewById(R.id.rebuild_detial_rebuild_state);
        rebuild_infalte_five = (ViewStub) view.findViewById(R.id.rebuild_detial_rest);

        //第四个  户厕重建情况
        View inflate_d = rebuild_infalte_four.inflate();
        d_rl_title = (RelativeLayout) inflate_d.findViewById(R.id.rebuild_info_state_title);
        d_image_arrow = (ImageView) inflate_d.findViewById(R.id.rebuild_info_state_iv_arrow);
        rebuild_info_state_show_body = (LinearLayout) inflate_d.findViewById(R.id.rebuild_info_state_show_body);

        d_state_name = (CBAlignTextView) inflate_d.findViewById(R.id.rebuild_info_state_name);
        d_state_address = (CBAlignTextView) inflate_d.findViewById(R.id.rebuild_info_state_address);
        d_state_trascode = (CBAlignTextView) inflate_d.findViewById(R.id.rebuild_info_state_trascode);
        d_state_tel = (CBAlignTextView) inflate_d.findViewById(R.id.rebuild_info_state_tel);

        //第五个  余下的布局
        View inflate_e = rebuild_infalte_five.inflate();

        five_rl_title = (AutoRelativeLayout) inflate_e.findViewById(R.id.rebuild_info_state_five_title);
        five_rl_image_arrow = (ImageView) inflate_e.findViewById(R.id.rebuild_info_state_five__arrow);
        five_rl_body = (AutoLinearLayout) inflate_e.findViewById(R.id.rebuild_info_state_five_body);

        allcceptanceuafeichi = (AutoLinearLayout) inflate_e.findViewById(R.id.all_acceptance_huafeichi);
        e_date_picker = (TextView) inflate_e.findViewById(R.id.rebuild_rest_date_picker);
        e_type_selected = (TextView) inflate_e.findViewById(R.id.rebuild_rest_type_selected);
        e_type_teamname = (TextView) inflate_e.findViewById(R.id.rebuild_rest_type_teamname);
        rebuild_rest_huafeichi = (TextView) inflate_e.findViewById(R.id.rebuild_rest_huafeichi);
        e_bt_save = (Button) inflate_e.findViewById(R.id.rebuild_rest_bt_save);
        e_rebuild_up_one = (AutoRelativeLayout) inflate_e.findViewById(R.id.rebuild_up_one);
        e_rebuild_up_two = (AutoRelativeLayout) inflate_e.findViewById(R.id.rebuild_up_two);
        all_show_a = (AutoLinearLayout) inflate_e.findViewById(R.id.all_show_a);
        all_show_b = (AutoLinearLayout) inflate_e.findViewById(R.id.all_show_b);
        e_rebuild_image_a = (ImageView) inflate_e.findViewById(R.id.rebuild_image_a);
        e_rebuild_image_b = (ImageView) inflate_e.findViewById(R.id.rebuild_image_b);

    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.fragment_rebuild_detial, container, false);
        detialLl = (AutoLinearLayout) view.findViewById(R.id.rebuild_detial_apply_ll);

        detialLl.setFocusable(true);
        detialLl.setFocusableInTouchMode(true);
        detialLl.requestFocus();

        return view;
    }


    /**
     * 初始化公用布局,如:toolbar  scrollview
     *
     * @param view
     */
    private void initView(View view) {
        EventBus.getDefault().register(this);

        //toolbar初始化
        applyBuySv = (ScrollView) view.findViewById(R.id.my_check_jescrollview);
        toolbarBack = (ImageView) view.findViewById(R.id.toolbar_back);
        toolbarTitle = (TextView) view.findViewById(R.id.toolbar_title);
        toolbar = (Toolbar) view.findViewById(R.id.toolbar);


        d_image_arrow.setVisibility(View.GONE);

        //取消化粪池材料
        rebuild_rest_huafeichi.setVisibility(View.GONE);
        allcceptanceuafeichi.setVisibility(View.GONE);
//============================================================
        //根据状态设置控件不可点击
        //获取传递过来的值
        Bundle arguments = getArguments();
        if (arguments != null) {
            rebuildData = (ReBuildItemEntity.DataBean) arguments.getSerializable(REBUILDDATA);

            //未重建  不可进行编辑
            if (!rebuildData.isEdit()) {
                //对应的控件设为预览状态
                //TODO
                e_date_picker.setEnabled(false);
                e_type_selected.setEnabled(false);
                e_type_teamname.setEnabled(false);
                e_bt_save.setEnabled(false);
                e_bt_save.setBackgroundResource(R.drawable.toilet_sliding_tv_unselected);

                //toolbarTitle.setText("户厕改造重建预览");

            } else {
                //toolbarTitle.setText("户厕改造重建");
            }

        }

//============================================================
        toolbarTitle.setText("户厕改造重建");
        //返回箭头
        toolbarBack.setVisibility(View.VISIBLE);

        //返回箭头功能 同步
        initToolbarBack(toolbar);

        //设置时间
        e_date_picker.setText("" + getNowTime());
        rebuildInfoEntity.setChongjian_time(e_date_picker.getText().toString());

    }

    /**
     * 得到当前时间
     */
    private String getNowTime() {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        Date curDate = new Date(System.currentTimeMillis());//获取当前时间
        String str = formatter.format(curDate);
        return str;
    }


    /**
     * 动画结束后执行
     * 通过handler加载布局
     *
     * @param savedInstanceState
     */
    @Override
    public void onEnterAnimationEnd(Bundle savedInstanceState) {
        super.onEnterAnimationEnd(savedInstanceState);
        showLoadingDialog("正在加载....");

        //获取权限
        showPermission();


        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                handler.sendEmptyMessage(LAYOUT_ONE);
            }
        }, 200);

        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                handler.sendEmptyMessage(LAYOUT_TWO);
            }
        }, 600);
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                handler.sendEmptyMessage(LAYOUT_THREE);
            }
        }, 1200);
    }


    private static final int REQUEST_CODE_SOME_FEATURES_PERMISSIONS = 111;
    private boolean isShowDialog = true;

    /**
     * 申请权限
     */
    private void showPermission() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            if (ContextCompat.checkSelfPermission(_mActivity, Manifest.permission.CAMERA)
                    != PackageManager.PERMISSION_GRANTED) {//  如果没有申请权限
                //申请phone WRITE_EXTERNAL_STORAGE权限
                ActivityCompat.requestPermissions(_mActivity,
                        new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE,
                                Manifest.permission.READ_EXTERNAL_STORAGE,
                                Manifest.permission.CAMERA},
                        REQUEST_CODE_SOME_FEATURES_PERMISSIONS);
            }
        }
    }

    /**
     * 权限回调
     *
     * @param requestCode
     * @param permissions
     * @param grantResults
     */
    @Override
    public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);

        switch (requestCode) {
            case REQUEST_CODE_SOME_FEATURES_PERMISSIONS: {
                System.out.println("Permissions --> " + permissions.length);
                for (int i = 0; i < permissions.length; i++) {
                    if (grantResults[i] == PackageManager.PERMISSION_GRANTED) {
                        System.out.println("Permissions --> " + "Permission Granted: " + permissions[i]);
                    } else if (grantResults[i] == PackageManager.PERMISSION_DENIED) {
                        System.out.println("Permissions     --> " + "Permission Denied: " + permissions[i]);
                        if (isShowDialog) {
                            isShowDialog = false;
                            showPermissionDialog();
                        }

                    }
                }
            }
            break;
            default: {
                super.onRequestPermissionsResult(requestCode, permissions, grantResults);
            }
        }

    }

    /**
     * 显示权限对话框
     */
    private void showPermissionDialog() {
        showAlertDialog(_mActivity, "权限申请", "为了您可以上传图片请打开此权限,点确认再次申请", new DialogClick() {
            @Override
            public void PositiveMessage() {
                showPermission();
            }

            @Override
            public void NegativeMessage() {
                showShortToast("您将无法上传图片信息");
                isShowDialog = true;
            }
        });
    }


    /**
     * 添加的各种监听
     */
    private void initListener() {
        a_rl_title.setOnClickListener(this);
        b_rl_title.setOnClickListener(this);
        c_rl_title.setOnClickListener(this);
        d_rl_title.setOnClickListener(this);
        five_rl_title.setOnClickListener(this);
        e_date_picker.setOnClickListener(this);
        e_type_selected.setOnClickListener(this);
        e_type_teamname.setOnClickListener(this);
        e_rebuild_up_one.setOnClickListener(this);
        e_rebuild_up_two.setOnClickListener(this);
        e_bt_save.setOnClickListener(this);
        //rebuild_rest_huafeichi.setOnClickListener(this);


        idcard_image.setOnClickListener(this);
        frontdoor_image.setOnClickListener(this);
        befor_image.setOnClickListener(this);
        after_image.setOnClickListener(this);
        ing_image.setOnClickListener(this);

    }

    private boolean isFirstView = false;
    private boolean isSecondView = false;
    private boolean isThirdView = false;
    private boolean isFourthView = true;

    /**
     * 各种点击事件
     *
     * @param view
     */
    @Override
    public void onClick(View view) {

        switch (view.getId()) {
            case R.id.rebuild_reform_state_title:
                //默认是关闭
                if (!isFirstView) {
                    Util.openView(rebuild_reform_state_show_body);//展开
                    Util.openImageView(a_image_arrow);
                    isFirstView = true;
                } else { //关闭
                    Util.clossView(rebuild_reform_state_show_body);
                    Util.closeImageView(a_image_arrow);
                    isFirstView = false;
                }
                break;
            case R.id.rebuild_detial_accept_title:
                //默认是关闭
                if (!isSecondView) {
                    Util.openView(check_accept_show_body);//展开
                    Util.openImageView(b_image_arrow);
                    isSecondView = true;
                } else { //关闭
                    Util.clossView(check_accept_show_body);
                    Util.closeImageView(b_image_arrow);
                    isSecondView = false;
                }
                break;
            case R.id.rebuild_check_state_title:
                //默认是关闭
                if (!isThirdView) {
                    Util.openView(rebuild_check_state_show_body);//展开
                    Util.openImageView(c_image_arrow);
                    isThirdView = true;
                } else { //关闭
                    Util.clossView(rebuild_check_state_show_body);
                    Util.closeImageView(c_image_arrow);
                    isThirdView = false;
                }
                break;

            case R.id.rebuild_info_state_five_title:
                //默认是关闭
                if (!isFourthView) {
                    Util.openView(five_rl_body);//展开
                    Util.openImageView(five_rl_image_arrow);
                    isFourthView = true;
                } else { //关闭
                    Util.clossView(five_rl_body);
                    Util.closeImageView(five_rl_image_arrow);
                    isFourthView = false;
                }

                break;

            case R.id.rebuild_info_state_title:
                // TODO: 2018/6/14 这个布局是多余的
                //默认是关闭
//                if (!isFourthView) {
//                    Util.openView(rebuild_info_state_show_body);//展开
//                    Util.openImageView(d_image_arrow);
//                    isFourthView = true;
//                } else { //关闭
//                    Util.clossView(rebuild_info_state_show_body);
//                    Util.closeImageView(d_image_arrow);
//                    isFourthView = false;
//                }
                break;

            //重建日期
            case R.id.rebuild_rest_date_picker:
                TimePickerView.Type type = TimePickerView.Type.YEAR_MONTH_DAY;
                pvTime = new TimePickerView(_mActivity, type);
                String format = "yyyy-MM-dd";
                UtilPop.alertTimerPickerEh(getActivity(), pvTime, format, new UtilPop.TimerPickerCallBack() {
                    @Override
                    public void onTimeSelect(String date) {
                        String nowTime = getNowTime();
                        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                        TimeUtils.getIntervalTime2(date, nowTime, ConstUtils.TimeUnit.DAY, sdf);
                        if (TimeUtils.getTypeValue() == 1) {
                            showShortToast("选择时间不能晚于当前时间");
                        } else {
                            //　选择时间　正确
                            e_date_picker.setText(date);

                            //添加验收时间
                            //saveparams.put("chongjian_time", date);
                            rebuildInfoEntity.setChongjian_time(date);
                        }
                    }
                });
                break;

            //改造类型
            case R.id.rebuild_rest_type_selected:

                //根据改造状态,请求改造类型
                getStateType(view);

                break;

            //施工队伍名称
            case R.id.rebuild_rest_type_teamname:

                //施工队伍
                if (ewbuildDetialentity != null) {
                    getShigongduiName(view, ewbuildDetialentity.getArea_id());
                }


                break;


//            case R.id.rebuild_rest_huafeichi:
//                // rebuild_rest_huafeichi.setFocusable(true);
//                break;

            case R.id.rebuild_up_one:
                //Toast.makeText(_mActivity, "上传第一张", Toast.LENGTH_SHORT).show();
                mLayoutType = 1;
                showPhotoPicker();


                break;
            case R.id.rebuild_up_two:
                // Toast.makeText(_mActivity, "上传第二张", Toast.LENGTH_SHORT).show();


                mLayoutType = 2;
                showPhotoPicker();

                break;
            case R.id.rebuild_rest_bt_save:

                //检查各个字段的值
                boolean isCheck = CheckFildValue();
                if (!isCheck) {
                    cancelLoadingDialog();
                    return;
                }

                AddNewUpFildData();

                break;

//===================点击放大图片=================================

            case R.id.rebuild_reform_state_idcard_image:
                GotoImageFg(idcard_image, "身份证正面");
                break;
            case R.id.rebuild_reform_state_frontdoor_image:
                GotoImageFg(frontdoor_image, "大门照");
                break;
            case R.id.rebuild_reform_state_befor_image:
                GotoImageFg(befor_image, "改造前");
                break;
            case R.id.rebuild_reform_state_ing_image:
                //GotoImageFg(ing_image, "改造中", "重建中");
                GotoImageFgAA(ing_image, "14", "16", tvIngIma);
                break;//14   16
            case R.id.rebuild_reform_state_after_image:
                // GotoImageFg(after_image, "改造后", "重建后");
                GotoImageFgAA(after_image, "15", "17", tvAfterIma);
                break;//15   17
            default:

                break;
        }

    }

    private void GotoImageFg(ImageView imageview, String contextValue) {

        if (imageview.getVisibility() == View.VISIBLE && acceptImageEntities != null
                && acceptImageEntities.size() > 0) {
            for (AcceptImageEntity acceptiamgedata : acceptImageEntities) {
                if (contextValue.equals(acceptiamgedata.getFile_des())) {
                    EventBus.getDefault().post(new StartNewFragmentEvent(ImageShowFragment.newInstance(acceptiamgedata.getSys_file_name())));
                }

            }
        }

    }


    private void GotoImageFgAA(ImageView imageview, String contextValue, String value
            , TextView tv) {

        if (imageview.getVisibility() == View.VISIBLE && acceptImageEntities != null
                && acceptImageEntities.size() > 0) {

            if (acceptImageEntities.size() > 5) {
                String image_desc = tv.getText().toString();

                for (AcceptImageEntity acceptiamgedata : acceptImageEntities) {
                    if (image_desc.equals(acceptiamgedata.getFile_des())) {
                        EventBus.getDefault().post(new StartNewFragmentEvent(ImageShowFragment.newInstance(acceptiamgedata.getSys_file_name())));
                        return;//http://192.168.60.14:8082/group1/M00/00/17/wKg8EltWl6uASSgGAAD1QR1UeQo49.jpeg
                    }
                }
            } else {
                for (AcceptImageEntity acceptiamgedata : acceptImageEntities) {
                    if (contextValue.equals(acceptiamgedata.getFile_des())) {
                        EventBus.getDefault().post(new StartNewFragmentEvent(ImageShowFragment.newInstance(acceptiamgedata.getSys_file_name())));
                        return;
                    }
                }
            }
//            for (AcceptImageEntity acceptiamgedata : acceptImageEntities) {
//                //重建中和改造中同时出现,选择重建中
//                if (value.equals(acceptiamgedata.getAdjunct_type())) {
//
//                    Log.i("重建的图片链接", "GotoImageFg: " + acceptiamgedata.getSys_file_name());
//                    EventBus.getDefault().post(new StartNewFragmentEvent(ImageShowFragment.newInstance(acceptiamgedata.getSys_file_name())));
//                    return;
//                }
//                if (contextValue.equals(acceptiamgedata.getAdjunct_type())) {
//
//                    EventBus.getDefault().post(new StartNewFragmentEvent(ImageShowFragment.newInstance(acceptiamgedata.getSys_file_name())));
//
//                    return;
//
//                }
//            }
        }
    }

    /**
     * 保存上传数据  rebuildDetialSaveUp
     */
    private void AddNewUpFildData() {
        if (ewbuildDetialentity == null) {
            return;
        }
        String url_rebuild_up = HttpApis.rebuildDetialSaveUp +
                ewbuildDetialentity.getChongjian_id();


        //后来补加
        //saveparams.put("opt_srcpage", "chongjian");
        //saveparams.put("idfield", "chongjian_id");

        rebuildInfoEntity.setOpt_srcpage("chongjian");
        rebuildInfoEntity.setIdfield("chongjian_id");

        Log.i("重建提交数据", "Url" + url_rebuild_up + "~~~~" + saveparams.size() + ":  AddNewUpFildData: " + saveparams.toString());

//        rebuildInfoEntity.setAdjunct_id(new String[]{one_ima[0], two_ima[0]});
//        rebuildInfoEntity.setSys_file_name(new String[]{one_ima[1], two_ima[1]});
//        rebuildInfoEntity.setAdjunct_type(new String[]{one_ima[2], two_ima[2]});
//        rebuildInfoEntity.setFile_type(new String[]{one_ima[3], two_ima[3]});
//        rebuildInfoEntity.setFile_size(new String[]{one_ima[4], two_ima[4]});
//        rebuildInfoEntity.setFile_des(new String[]{one_ima[5], two_ima[5]});
//        rebuildInfoEntity.setUser_file_name(new String[]{one_ima[6], two_ima[6]});

        rebuildInfoEntity.setAdjunct_id(new String[]{before_ima[0], ing_ima[0], after_ima[0], idcard_ima[0], fodoor_ima[0], one_ima[0], two_ima[0]});
        rebuildInfoEntity.setSys_file_name(new String[]{before_ima[1], ing_ima[1], after_ima[1], idcard_ima[1], fodoor_ima[1], one_ima[1], two_ima[1]});
        rebuildInfoEntity.setAdjunct_type(new String[]{before_ima[2], ing_ima[2], after_ima[2], idcard_ima[2], fodoor_ima[2], one_ima[2], two_ima[2]});
        rebuildInfoEntity.setFile_type(new String[]{before_ima[3], ing_ima[3], after_ima[3], idcard_ima[3], fodoor_ima[3], one_ima[3], two_ima[3]});
        rebuildInfoEntity.setFile_size(new String[]{before_ima[4], ing_ima[4], after_ima[4], idcard_ima[4], fodoor_ima[4], one_ima[4], two_ima[4]});
        rebuildInfoEntity.setFile_des(new String[]{before_ima[5], ing_ima[5], after_ima[5], idcard_ima[5], fodoor_ima[5], one_ima[5], two_ima[5]});
        rebuildInfoEntity.setUser_file_name(new String[]{before_ima[6], ing_ima[6], after_ima[6], idcard_ima[6], fodoor_ima[6], one_ima[6], two_ima[6]});


        Log.i("重建提交数据", "url: " + url_rebuild_up);


        HttpUtils.requestPostGson(_mActivity, url_rebuild_up, rebuildInfoEntity, new Request() {
            @Override
            public void success(String jsonStr) {
                super.success(jsonStr);

                Log.i("重建提交数据", "success: " + jsonStr);

                FIleEditSaveUpEntity fileeditip = GsonTools.changeGsonToBean(jsonStr, FIleEditSaveUpEntity.class);

                if (fileeditip != null && "success".equals(fileeditip.getState())) {
                    Toast.makeText(_mActivity, "上传成功!", Toast.LENGTH_SHORT).show();

                    //恢复默认值

                    e_type_selected.setText("下拉选择改造类型");
                    e_type_teamname.setText("下拉选择施工队伍");
                    // rebuild_rest_huafeichi.setText("");
                    // rebuild_rest_huafeichi.setHint("请输入");

                    // rebuild_rest_huafeichi.setFocusable(false);

                    //图片状态重置
                    all_show_a.setVisibility(View.VISIBLE);
                    all_show_b.setVisibility(View.VISIBLE);
                    e_rebuild_image_a.setVisibility(View.GONE);
                    e_rebuild_image_b.setVisibility(View.GONE);


                    //清空集合

                    saveparams.clear();

                    EventBus.getDefault().post(new MessageEvent("361"));

                    //返回列表页
                    _mActivity.onBackPressed();


                }

                cancelLoadingDialog();
            }

            @Override
            public void error(String error) {
                super.error(error);
                Log.i("重建提交数据", "error: " + error);
                showShortToast("保存提交失败");
                cancelLoadingDialog();
            }


        });

//        HttpUtils.requestPost(_mActivity, url_rebuild_up, saveparams, new Request() {
//            @Override
//            public void success(String jsonStr) {
//                super.success(jsonStr);
//
//                Log.i("重建提交数据", "success: " + jsonStr);
//
//                FIleEditSaveUpEntity fileeditip = GsonTools.changeGsonToBean(jsonStr, FIleEditSaveUpEntity.class);
//
//                if (fileeditip != null && "success".equals(fileeditip.getState())) {
//                    Toast.makeText(_mActivity, "上传成功!", Toast.LENGTH_SHORT).show();
//
//                    //恢复默认值
//
//                    e_type_selected.setText("下拉选择改造类型");
//                    e_type_teamname.setText("下拉选择施工队伍");
//                    rebuild_rest_huafeichi.setText("");
//                    rebuild_rest_huafeichi.setHint("请输入");
//
//                   // rebuild_rest_huafeichi.setFocusable(false);
//
//                    //图片状态重置
//                    all_show_a.setVisibility(View.VISIBLE);
//                    all_show_b.setVisibility(View.VISIBLE);
//                    e_rebuild_image_a.setVisibility(View.GONE);
//                    e_rebuild_image_b.setVisibility(View.GONE);
//
//
//                    //清空集合
//
//                    saveparams.clear();
//
//
//                }
//
//                cancelLoadingDialog();
//            }
//
//            @Override
//            public void error(String error) {
//                super.error(error);
//                Log.i("重建提交数据", "error: " + error);
//
//                cancelLoadingDialog();
//            }
//
//
//        });
    }


    /**
     * 检查各个字段对应的数值,辖区单位进行拼接
     */
    private boolean CheckFildValue() {

        //重建时间
//        if (saveparams.size() < 1) {
//            showShortToast("请选择重建时间");
//            return false;
//        }


        //重建  改造类型
        String build_type_name = e_type_selected.getText().toString().trim();
        if (TextUtils.isEmpty(build_type_name) || "下拉选择改造类型".equals(build_type_name)) {
            Toast.makeText(_mActivity, "请选择改造类型", Toast.LENGTH_SHORT).show();
            return false;
        }

        //施工队伍
        String shigteamname = e_type_teamname.getText().toString().trim();
        if (TextUtils.isEmpty(shigteamname) || "下拉选择施工队伍".equals(shigteamname)) {
            Toast.makeText(_mActivity, "施工队伍格式不正确", Toast.LENGTH_SHORT).show();
            return false;
        }


        //化肥池材料
//        String huafcM = rebuild_rest_huafeichi.getText().toString().trim();
//        if (TextUtils.isEmpty(huafcM)) {
//            Toast.makeText(_mActivity, "化肥池材料格式不正确", Toast.LENGTH_SHORT).show();
//            return false;
//        } else {
//            //saveparams.put("hfc_material", huafcM);
//            rebuildInfoEntity.setHfc_material(huafcM);
//        }

        //提示上传图片
        if (!isImageFirst || !isImageSecond) {
            showShortToast("请上传图片");
            return false;
        } else {
            return true;
        }

    }


    /**
     * 显示图片选择
     */
    private void showPhotoPicker() {
        PhotoPicker.builder()
                .setPhotoCount(1) //显示图片张
                .setPreviewEnabled(false)
                .start(_mActivity, this, PhotoPicker.REQUEST_CODE);

    }

    /**
     * 获取图库返回的图片
     *
     * @param requestCode
     * @param resultCode
     * @param data
     */
    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == Activity.RESULT_CANCELED) {
            return;
        }
        if (resultCode == RESULT_OK && requestCode == PhotoPicker.REQUEST_CODE && data != null) {
            LogUtils.e("显示", "onActivityResult");

            ArrayList<String> photos = data.getStringArrayListExtra(PhotoPicker.KEY_SELECTED_PHOTOS);

            showLoadingDialog("正在上传图片");
            for (int i = 0; i < photos.size(); i++) {
                String uri = Uri.decode(photos.get(i));
                LogUtils.e("uri", uri);
                try {
                    compressWithRx(new File(uri));
                } catch (Exception e) {
                    Toast.makeText(_mActivity, "请重新上传", Toast.LENGTH_SHORT).show();

                }
            }

        }
    }


    /**
     * 压缩单张图片 RxJava 方式
     */
    private void compressWithRx(File file) throws Exception {

        Flowable.just(file)
                .observeOn(Schedulers.io())
                .map(new Function<File, File>() {
                    @Override
                    public File apply(@NonNull File file) {//  throws Exception
                        try {
                            File file1 = Luban.with(_mActivity).load(file).get();
                            return file1;
                        } catch (Exception e) {
                            //对于文件损坏的文件/压缩失败的文件,也能上传,但是,在主线程中提示
                            //记住,修改权限
                            _mActivity.runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    //Toast.makeText(_mActivity, "请重新上传", Toast.LENGTH_SHORT).show();
                                    showShortToast("请重新上传");
                                }
                            });

                            return file;
                        }
                        //return Luban.with(_mActivity).load(file).get();

                    }
                })
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer<File>() {
                    @Override
                    public void accept(@NonNull File file) {
                        LogUtils.e("fileinfo", "file- " + file.length() / 1024 + "k" + " name- " + file.getName() + " paht- " + file.getPath());
                        //上传图片
                        if (file == null) {
                            Toast.makeText(_mActivity, "请重新上传", Toast.LENGTH_SHORT).show();
                        } else {
                            uploadImgFile(file, file.getName(), file.getPath());
                        }

                    }


                });


    }


    /**
     * 上传单张图片
     *
     * @param file
     * @param fileName
     */
    private void uploadImgFile(final File file, final String fileName, final String filepath) {
        //uploadFile
        //http://192.168.70.188:8080/rest/adj/upload
        //String url="http://192.168.70.188:8080/rest/adj/upload";
        String url = HttpApis.upload_image;
        HttpUtils.requestPostFileUploades(getActivity(), url, fileName, file, new Request() {
            @Override
            public void success(String jsonStr) {
                super.success(jsonStr);
                LogUtils.e("上传图片成功", "jsonSuccess  " + jsonStr + "~~~" + fileName);
                UploadImageEntity uploadImageEntity = GsonTools.changeGsonToBean(jsonStr, UploadImageEntity.class);
                if ("SUCCESS".equals(uploadImageEntity.getState())) {
                    isUploadSuccess = true;

                    // uploadFileCustomEntity = new UploadFileCustomEntity(uploadImageEntity.getUrl(), filepath, uploadImageEntity.getSize(), uploadImageEntity.getType());

                    displayUploadImgFile(uploadImageEntity, fileName);  //将img显示

                } else {
                    showShortToast("上传失败，图片大小不能超过4兆");
                    isUploadSuccess = false;
                }

                cancelLoadingDialog();
            }

            @Override
            public void error(String error) {
                super.error(error);
                isUploadSuccess = false;
                cancelLoadingDialog();
            }
        });

    }


    //5张图片是否上传成功的状态
    private boolean isImageFirst;
    private boolean isImageSecond;

    private void displayUploadImgFile(UploadImageEntity uploadImageEntity, String filename) {
        switch (mLayoutType) {
            case 1:

                all_show_a.setVisibility(View.GONE);
                e_rebuild_image_a.setVisibility(View.VISIBLE);
                LogUtils.e("上传图片成功", "展示图片 1 " + uploadImageEntity.getFilePath());
                Glide.with(_mActivity).load(uploadImageEntity.getFilePath()).into(e_rebuild_image_a);


                one_ima[0] = uploadImageEntity.getFileID();
                one_ima[1] = uploadImageEntity.getFilePath();
                one_ima[2] = "16";//adjunct_type : 据上传图片定
                one_ima[3] = uploadImageEntity.getFileExt();
                one_ima[4] = uploadImageEntity.getSize();
                one_ima[5] = "重建中";//file_des:据上传图片定 身份证正面\大门照
                one_ima[6] = uploadImageEntity.getFileName();


                if (isUploadSuccess) {
                    isImageFirst = isUploadSuccess;
                }
                break;
            case 2:

                all_show_b.setVisibility(View.GONE);
                e_rebuild_image_b.setVisibility(View.VISIBLE);
                LogUtils.e("上传图片成功", "展示图片 2 " + uploadImageEntity.getFilePath());
                Glide.with(_mActivity).load(uploadImageEntity.getFilePath()).into(e_rebuild_image_b);

                two_ima[0] = uploadImageEntity.getFileID();
                two_ima[1] = uploadImageEntity.getFilePath();
                two_ima[2] = "17";//adjunct_type : 据上传图片定
                two_ima[3] = uploadImageEntity.getFileExt();
                two_ima[4] = uploadImageEntity.getSize();
                two_ima[5] = "重建后";//file_des:据上传图片定 身份证正面\大门照
                two_ima[6] = uploadImageEntity.getFileName();


                if (isUploadSuccess) {
                    isImageSecond = isUploadSuccess;
                }
                break;
            default:

                break;

        }

    }


    /**
     * 获取施工队
     *
     * @param area_id
     */
    private void getShigongduiName(final View view, String area_id) {
        String areaid = area_id.substring(0, 9);

        String shigongteamUrl = HttpApis.addnew_teamdata + areaid;
        Log.i("重建详情施工队", "url: " + shigongteamUrl);
        showLoadingDialog("施工队...");
        HttpUtils.requestGet(_mActivity, shigongteamUrl, new Request() {

            @Override
            public void success(String jsonStr) {
                super.success(jsonStr);

                Log.i("重建详情施工队", "success: " + jsonStr);

                Type type = new TypeToken<ArrayList<AddNewShiGongTeamEntity>>() {
                }.getType();

                buildteam_resaultlist = JsonUtil.json2Collection(jsonStr, type);

                showShigongTeamPopu(view);

                cancelLoadingDialog();
            }

            @Override
            public void error(String error) {
                super.error(error);
                Log.i("重建详情施工队", "error: " + error);

                cancelLoadingDialog();
            }
        });


    }

    /**
     * 显示施工队popuwindow
     *
     * @param view
     */
    private void showShigongTeamPopu(View view) {

        buildteam_popupWindow = new ListPopupWindow(_mActivity);

        setShigTeamPopuData(view, buildteam_popupWindow, buildteam_resaultlist);
        setShigongTeamPopuClickListener(new AddNewShigTeamPopuListener() {
            @Override
            public void show(AddNewShiGongTeamEntity cetity, String mess) {
                e_type_teamname.setText(mess);

                // TODO: 2018/6/19 施工队
                //saveparams.put("shgd_name_cj", cetity.getText());
                //saveparams.put("shgd_id_cj", cetity.getValue());

                rebuildInfoEntity.setShgd_id_cj(cetity.getValue());
                rebuildInfoEntity.setShgd_name_cj(cetity.getText());
            }
        });
    }

    /**
     * 根据改造状态获取改造类型
     */
    private void getStateType(View view) {

        if (ewbuildDetialentity != null) {
            String state_build = ewbuildDetialentity.getGaizao_state_n();
            switch (state_build) {
                case "已改造":
                case "未改造":
                case "改造中":
                    getFontTypeData(view);
                    break;
                case "旧有改造":
                    getLastTypeData(view);
                    break;

                default:

                    break;
            }
        }

    }


    /**
     * 获取前三种改造状态对应的改造类型
     */
    private void getFontTypeData(final View view) {
        String the_threeurl = HttpApis.addnew_fontThree;
        Log.i("前三个状态", "url: " + the_threeurl);
        showLoadingDialog("改造类型...");
        HttpUtils.requestGet(_mActivity, the_threeurl, new Request() {
            @Override
            public void success(String jsonStr) {
                super.success(jsonStr);

                Log.i("前三个状态", "success: " + jsonStr);

                Type type = new TypeToken<ArrayList<AddNewBuildTypeEntity>>() {
                }.getType();

                buildtype_resaultlist = JsonUtil.json2Collection(jsonStr, type);

                showBuildTypePopu(view);

                cancelLoadingDialog();
            }

            @Override
            public void error(String error) {
                super.error(error);
                Log.i("前三个状态", "error: " + error);

                cancelLoadingDialog();
            }
        });

    }


    /**
     * 获取第四种改造状态对应的改造类型
     */
    private void getLastTypeData(final View view) {
        String the_last = HttpApis.addnew_last;
        Log.i("第四个状态", "url: " + the_last);
        showLoadingDialog("改造类型...");
        HttpUtils.requestGet(_mActivity, the_last, new Request() {
            @Override
            public void success(String jsonStr) {
                super.success(jsonStr);

                Log.i("第四个状态", "success: " + jsonStr);

                Type type = new TypeToken<ArrayList<AddNewBuildTypeEntity>>() {
                }.getType();

                buildtype_resaultlist = JsonUtil.json2Collection(jsonStr, type);

                showBuildTypePopu(view);

                cancelLoadingDialog();
            }

            @Override
            public void error(String error) {
                super.error(error);
                Log.i("前三个状态", "error: " + error);

                cancelLoadingDialog();
            }
        });
    }


    /**
     * 显示改造类型popuwindow
     *
     * @param view
     */
    private void showBuildTypePopu(View view) {

        //改造类型,根据改造状态来请求数据

        buildtype_popupWindow = new ListPopupWindow(_mActivity);

        setbuildTypePopuData(view, buildtype_popupWindow, buildtype_resaultlist);
        setbuildTypePopuClickListener(new AddNewBuildTypePopuListener() {
            @Override
            public void show(AddNewBuildTypeEntity cetity, String mess) {
                e_type_selected.setText(mess);
                //saveparams.put("gaizao_type_cj",cetity.getValue());
                //saveparams.put("gaizao_type_n_cj",cetity.getText());

                rebuildInfoEntity.setGaizao_type_cj(cetity.getValue());
                rebuildInfoEntity.setGaizao_type_n_cj(cetity.getText());
            }
        });
    }


//----------------------------改造类型popudata---------------------------------------------------------------

    private List<String> addnewtypelist = new ArrayList<>();


    private void setbuildTypePopuData(View view, final ListPopupWindow mPopupWindow, final List<AddNewBuildTypeEntity> datalist) {

        addnewtypelist.clear();
        for (AddNewBuildTypeEntity abte : datalist) {
            addnewtypelist.add(abte.getText());
        }

        ArrayAdapter<String> adapter = new ArrayAdapter<>(_mActivity, android.R.layout.simple_list_item_1, addnewtypelist);
        mPopupWindow.setAdapter(adapter);

        //弹出的位置  弹出锚点
        mPopupWindow.setAnchorView(view);
        //设置宽高
        mPopupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
        mPopupWindow.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);

        mPopupWindow.setModal(true);//设置模态框，设置为true响应物理键
        //设置条目点击事件
        mPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                //使用回调,显示数据
                if (anbtbtClickListener != null) {
                    anbtbtClickListener.show(datalist.get(position), addnewtypelist.get(position));
                }
                mPopupWindow.dismiss();
            }
        });
        mPopupWindow.show();
    }

    public AddNewBuildTypePopuListener anbtbtClickListener;

    public void setbuildTypePopuClickListener(AddNewBuildTypePopuListener popudefaultClickListener) {
        this.anbtbtClickListener = popudefaultClickListener;
    }
//----------------------------改造类型popudata----------------------------------------------------


//----------------------------施工队popudata---------------------------------------------------------------


    private List<String> addnewshigtlist = new ArrayList<>();

    private void setShigTeamPopuData(View view, final ListPopupWindow mPopupWindow, final List<AddNewShiGongTeamEntity> datalist) {

        addnewshigtlist.clear();
        for (AddNewShiGongTeamEntity abte : datalist) {
            addnewshigtlist.add(abte.getText());
        }

        ArrayAdapter<String> adapter = new ArrayAdapter<>(_mActivity, android.R.layout.simple_list_item_1, addnewshigtlist);
        mPopupWindow.setAdapter(adapter);

        //弹出的位置  弹出锚点
        mPopupWindow.setAnchorView(view);
        //设置宽高
        mPopupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
        mPopupWindow.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);

        mPopupWindow.setModal(true);//设置模态框，设置为true响应物理键
        //设置条目点击事件
        mPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                //使用回调,显示数据
                if (anshigongteamClickListener != null) {
                    anshigongteamClickListener.show(datalist.get(position), addnewshigtlist.get(position));
                }
                mPopupWindow.dismiss();
            }
        });
        mPopupWindow.show();
    }

    public AddNewShigTeamPopuListener anshigongteamClickListener;

    public void setShigongTeamPopuClickListener(AddNewShigTeamPopuListener anshigongteamClickListener) {
        this.anshigongteamClickListener = anshigongteamClickListener;
    }


//----------------------------施工队popudata---------------------------------------------------------------


    /**
     * eventBus接受数据
     *
     * @param center
     */
    @Subscribe
    public void onEventThread(EventCenter center) {
        //显示供货单位
        if (center.getEventCode() == EventConstant.ORG_SUPPLY_INFOR_INDEX) {
            String orgID = (String) center.getData();
            // querySupplyOrgData(orgID);
            Log.i("thisthisthat", "onEventThread: " + orgID);

        }

    }


    /**
     * 加载数据    根据不同的buyCertId加载出是查看状态还是可编辑状态
     */
    private void loadMoreData() {
        //加载user信息
        if (rebuildData != null) {
            String rebuild_detial_url = HttpApis.rebuildDetial_Data + rebuildData.getChongjian_id();
            Log.i("重建详情数据", "url:" + rebuild_detial_url);
            if (request == null) {
                request = new RebuildDetileRequest();
            }
            HttpUtils.requestGet(_mActivity, rebuild_detial_url, request);

            //获取图片数据
            getRebuildImageData(rebuildData.getChongjian_id());


        }

    }


    /**
     * 获取图片数据
     *
     * @param chongjian_id
     */
    private void getRebuildImageData(String chongjian_id) {
        //
        final String accept_image_data = HttpApis.rebuildtDetial_image;//+acceptid

        Log.i("重建详情图片数据", accept_image_data);
        Map<String, String> params = new TreeMap<>();
        params.put("mid", chongjian_id);

        HttpUtils.requestPost(_mActivity, accept_image_data, params, new Request() {
            @Override
            public void success(String jsonStr) {
                super.success(jsonStr);
                Log.i("重建详情图片数据", jsonStr);

                Type type = new TypeToken<ArrayList<AcceptImageEntity>>() {
                }.getType();

                acceptImageEntities = json2Collection(jsonStr, type);

                if (acceptImageEntities != null && acceptImageEntities.size() > 0) {

                    if (acceptImageEntities.size() == 5) {
                        for (AcceptImageEntity acceptiamgedata : acceptImageEntities) {

                            processImageData(acceptiamgedata);
                            Log.i("重建详情图片数据", acceptiamgedata.getAdjunct_type() + "::" + acceptiamgedata.getFile_des() + "::" + acceptiamgedata.getSys_file_name());
                        }
                    } else if (acceptImageEntities.size() == 7) {

                        for (AcceptImageEntity acceptiamgedata : acceptImageEntities) {
                            String opt_time = acceptiamgedata.getOpt_time();
                            long time=Long.parseLong(opt_time);//long now = android.os.SystemClock.uptimeMillis();
                            SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                            Date d1=new Date(time);
                            String t1=format.format(d1);
                            Log.i("重建详情图片数据", "时间:"+t1+"::"+acceptiamgedata.getAdjunct_type() + "::" + acceptiamgedata.getFile_des() + "::" + acceptiamgedata.getSys_file_name());


                            if ("14".equals(acceptiamgedata.getAdjunct_type())
                                    || "15".equals(acceptiamgedata.getAdjunct_type())) {
                                continue;
                            }
                            processImageData(acceptiamgedata);
                        }
                    }
                }

                cancelLoadingDialog();
            }

            @Override
            public void error(String error) {
                super.error(error);
                Log.i("重建详情图片数据", error);
                cancelLoadingDialog();
            }
        });

    }

    /**
     * 加载重建详情图片数据
     *
     * @param acceptiamgedata
     */
    private void processImageData(AcceptImageEntity acceptiamgedata) {
        switch (acceptiamgedata.getAdjunct_type()) {
            case "13":
                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), befor_image);
                //Glide.with(_mActivity).load(acceptiamgedata.getSys_file_name()).diskCacheStrategy(DiskCacheStrategy.ALL).centerCrop().into(befor_image);
                tvBeforIma.setText(acceptiamgedata.getFile_des());

                before_ima[0] = acceptiamgedata.getAdjunct_id();
                before_ima[1] = acceptiamgedata.getSys_file_name();
                before_ima[2] = "13";//adjunct_type : 据上传图片定
                before_ima[3] = acceptiamgedata.getFile_type();
                before_ima[4] = acceptiamgedata.getFile_size();
                before_ima[5] = "改造前";//file_des:据上传图片定 身份证正面\大门照
                before_ima[6] = acceptiamgedata.getUser_file_name();
                break;

            case "14":


                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), ing_image);
                tvIngIma.setText(acceptiamgedata.getFile_des());

                ing_ima[0] = acceptiamgedata.getAdjunct_id();
                ing_ima[1] = acceptiamgedata.getSys_file_name();
                ing_ima[2] = "14";//adjunct_type : 据上传图片定
                ing_ima[3] = acceptiamgedata.getFile_type();
                ing_ima[4] = acceptiamgedata.getFile_size();
                ing_ima[5] = "改造中";//file_des:据上传图片定 身份证正面\大门照
                ing_ima[6] = acceptiamgedata.getUser_file_name();

                break;

            case "15":
                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), after_image);
                tvAfterIma.setText(acceptiamgedata.getFile_des());
                after_ima[0] = acceptiamgedata.getAdjunct_id();
                after_ima[1] = acceptiamgedata.getSys_file_name();
                after_ima[2] = "15";//adjunct_type : 据上传图片定
                after_ima[3] = acceptiamgedata.getFile_type();
                after_ima[4] = acceptiamgedata.getFile_size();
                after_ima[5] = "改造后";//file_des:据上传图片定 身份证正面\大门照
                after_ima[6] = acceptiamgedata.getUser_file_name();

                break;
            case "11":
                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), idcard_image);
                tvIdcardIma.setText(acceptiamgedata.getFile_des());
                idcard_ima[0] = acceptiamgedata.getAdjunct_id();
                idcard_ima[1] = acceptiamgedata.getSys_file_name();
                idcard_ima[2] = "11";//adjunct_type : 据上传图片定
                idcard_ima[3] = acceptiamgedata.getFile_type();
                idcard_ima[4] = acceptiamgedata.getFile_size();
                idcard_ima[5] = "身份证正面";//file_des:据上传图片定 身份证正面\大门照
                idcard_ima[6] = acceptiamgedata.getUser_file_name();

                break;
            case "12":
                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), frontdoor_image);
                tvFrontdoorIma.setText(acceptiamgedata.getFile_des());
                fodoor_ima[0] = acceptiamgedata.getAdjunct_id();
                fodoor_ima[1] = acceptiamgedata.getSys_file_name();
                fodoor_ima[2] = "12";//adjunct_type : 据上传图片定
                fodoor_ima[3] = acceptiamgedata.getFile_type();
                fodoor_ima[4] = acceptiamgedata.getFile_size();
                fodoor_ima[5] = "大门照";//file_des:据上传图片定 身份证正面\大门照
                fodoor_ima[6] = acceptiamgedata.getUser_file_name();

                break;

            case "16":
                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), ing_image);
                tvIngIma.setText(acceptiamgedata.getFile_des());
                one_ima[0] = acceptiamgedata.getAdjunct_id();
                one_ima[1] = acceptiamgedata.getSys_file_name();
                one_ima[2] = "16";//adjunct_type : 据上传图片定
                one_ima[3] = acceptiamgedata.getFile_type();
                one_ima[4] = acceptiamgedata.getFile_size();
                one_ima[5] = "重建中";//file_des:据上传图片定 身份证正面\大门照
                one_ima[6] = acceptiamgedata.getUser_file_name();


                break;

            case "17":
                ImageLoaderUtils.setImageUrl(_mActivity, acceptiamgedata.getSys_file_name(), after_image);
                tvAfterIma.setText(acceptiamgedata.getFile_des());
                two_ima[0] = acceptiamgedata.getAdjunct_id();
                two_ima[1] = acceptiamgedata.getSys_file_name();
                two_ima[2] = "17";//adjunct_type : 据上传图片定
                two_ima[3] = acceptiamgedata.getFile_type();
                two_ima[4] = acceptiamgedata.getFile_size();
                two_ima[5] = "重建后";//file_des:据上传图片定 身份证正面\大门照
                two_ima[6] = acceptiamgedata.getUser_file_name();
                break;

            default:

                break;
        }

    }

    /**
     * 请求详情数据
     */
    private class RebuildDetileRequest extends Request {

        @Override
        public void success(String jsonStr) {
            super.success(jsonStr);
            Log.i("重建详情数据", "success" + jsonStr);

            //处理修改的数据
            ewbuildDetialentity = GsonTools.changeGsonToBean(jsonStr, RebuildDetialEntity.class);
            if (ewbuildDetialentity != null) {
                processModfiyData(ewbuildDetialentity);
            }

            cancelLoadingDialog();
        }

        @Override
        public void error(String error) {
            super.error(error);
            Log.i("重建详情数据", "error" + error);
            cancelLoadingDialog();
        }
    }

    /**
     * 加载详情数据
     *
     * @param ewbuildDetialentity
     */
    private void processModfiyData(RebuildDetialEntity ewbuildDetialentity) {

        //改造情况
        a_tv_locate.setText(ewbuildDetialentity.getArea_name());
        a_tv_add.setText(ewbuildDetialentity.getMenpaihao());
        a_tv_doorname.setText(ewbuildDetialentity.getHuming());
        a_tv_househole_name.setText(ewbuildDetialentity.getHubianhao());
        a_tv_id_num.setText(ewbuildDetialentity.getCert_no());

        a_tv_humans.setText(ewbuildDetialentity.getRenkou());
        a_tv_phone.setText(ewbuildDetialentity.getPhone());

        a_tv_isidle.setText(ewbuildDetialentity.getXianzhi_n());
        a_tv_build_state.setText(ewbuildDetialentity.getGaizao_state_n());
        a_tv_build_type.setText(ewbuildDetialentity.getGaizao_type_n());
        a_tv_team_name.setText(ewbuildDetialentity.getShgd_name());
        a_tv_material.setText(ewbuildDetialentity.getHfc_material_n());

        a_tv_bianchi.setText(ewbuildDetialentity.getBianchi_n());
        a_tv_chongshui.setText(ewbuildDetialentity.getChongshuifangshi_n());
        a_tv_cefang.setText(ewbuildDetialentity.getCefang_n());


        //验收情况
        setQuestionValue(ewbuildDetialentity.getBili(), b_ques_half);
        setQuestionValue(ewbuildDetialentity.getRongjifuhe(), b_ques_one);
        setQuestionValue(ewbuildDetialentity.getShenduhege(), b_ques_two);
        setQuestionValue(ewbuildDetialentity.getGuandaoguifan(), b_ques_three);
        setQuestionValue(ewbuildDetialentity.getFengeshenshui(), b_ques_four);
        setQuestionValue(ewbuildDetialentity.getLiuguanchakou(), b_ques_five);

        setQuestionValue(ewbuildDetialentity.getCailiaofuhe(), b_ques_five_six);
        setQuestionValue(ewbuildDetialentity.getYoucefang(), b_ques_five_seven);
        setQuestionValue(ewbuildDetialentity.getYouding(), b_ques_five_eight);
        setQuestionValue(ewbuildDetialentity.getYoumen(), b_ques_five_nine);
        setQuestionValue(ewbuildDetialentity.getFangying(), b_ques_five_ten);
        setQuestionValue(ewbuildDetialentity.getFangdong(), b_ques_five_eleven);
        setQuestionValue(ewbuildDetialentity.getFangchou(), b_ques_five_twelve);

        b_ques_six.setText(ewbuildDetialentity.getYanshou_result_n());
        b_ques_seven.setText(ewbuildDetialentity.getYanshou_opt_n());

        long timeStap = ewbuildDetialentity.getYanshou_time();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String day = sdf.format(new Date(Long.parseLong(String.valueOf(timeStap))));
        b_ques_eight.setText(day);
        b_ques_nine.setText(ewbuildDetialentity.getYanshou_remark());


        //检查情况
        setQuestionValue(ewbuildDetialentity.getBili_jc(), cheigher_half_ch);
        setQuestionValue(ewbuildDetialentity.getRongjifuhe_jc(), cheigher_one_ch);
        setQuestionValue(ewbuildDetialentity.getShenduhege_jc(), cheigher_two_ch);
        setQuestionValue(ewbuildDetialentity.getGuandaoguifan_jc(), cheigher_three_ch);
        setQuestionValue(ewbuildDetialentity.getFengeshenshui_jc(), cheigher_four_ch);
        setQuestionValue(ewbuildDetialentity.getLiuguanchakou_jc(), cheigher_five_ch);

        setQuestionValue(ewbuildDetialentity.getCailiaofuhe_jc(), cheigher_five_six_ch);
        setQuestionValue(ewbuildDetialentity.getYoucefang_jc(), cheigher_five_seven_ch);
        setQuestionValue(ewbuildDetialentity.getYouding_jc(), cheigher_five_eight_ch);
        setQuestionValue(ewbuildDetialentity.getYoumen_jc(), cheigher_five_nine_ch);
        setQuestionValue(ewbuildDetialentity.getFangying_jc(), cheigher_five_ten_ch);
        setQuestionValue(ewbuildDetialentity.getFangdong_jc(), cheigher_five_eleven_ch);
        setQuestionValue(ewbuildDetialentity.getFangchou_jc(), cheigher_five_twelve_ch);


        //cheigher_six_ch.setText(ewbuildDetialentity.getJiancha_result_n());
        if ("0".equals(ewbuildDetialentity.getJiancha_result())) {
            cheigher_six_ch.setText("不合格");//jiancha_result
        } else if ("1".equals(ewbuildDetialentity.getJiancha_result())) {
            cheigher_six_ch.setText("合格");
        }


        cheigher_seven_ch.setText(ewbuildDetialentity.getJiancha_opt_n());

        long timeStapa = ewbuildDetialentity.getJiancha_time();
        SimpleDateFormat sdfa = new SimpleDateFormat("yyyy-MM-dd");
        String daya = sdfa.format(new Date(Long.parseLong(String.valueOf(timeStapa))));
        cheigher_eight_ch.setText(daya);
        cheigher_nine_ch.setText(ewbuildDetialentity.getJiancha_remark());

        //重建信息
        //重建日期chongjian_time_str
        e_date_picker.setText(ewbuildDetialentity.getChongjian_time_str());
        rebuildInfoEntity.setChongjian_time(ewbuildDetialentity.getChongjian_time_str());
        //改造类型
        e_type_selected.setText(ewbuildDetialentity.getGaizao_type_n_cj());
        rebuildInfoEntity.setGaizao_type_cj(ewbuildDetialentity.getGaizao_type_cj());
        rebuildInfoEntity.setGaizao_type_n_cj(ewbuildDetialentity.getGaizao_type_n_cj());
        //施工队名称
        e_type_teamname.setText(ewbuildDetialentity.getShgd_name_cj());
        rebuildInfoEntity.setShgd_id_cj(ewbuildDetialentity.getShgd_name());
        rebuildInfoEntity.setShgd_name_cj(ewbuildDetialentity.getShgd_name_cj());


    }

    /**
     * 赋值
     *
     * @param value
     * @param tv
     */
    private void setQuestionValue(String value, TextView tv) {
        if (value != null && tv != null) {
            if ("1".equals(value)) {
                tv.setText("是");
            } else {
                tv.setText("否");
            }
        }

    }


    @Override
    public void onPause() {
        super.onPause();
        if (pvTime != null && pvTime.isShowing()) {
            pvTime.dismiss();
        }
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();

        if (pvTime != null && pvTime.isShowing()) {
            pvTime.dismiss();
            pvTime = null;
        }
        EventBus.getDefault().unregister(this);
        OkHttpUtils.getInstance().cancelTag(this);
        cancelLoadingDialog();
        handler.removeCallbacksAndMessages(null);
    }


}
